package comxin.demo1.pooldemo;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.mchange.v2.c3p0.DataSources;

import javax.sql.DataSource;
import java.beans.PropertyVetoException;
import java.sql.Connection;
import java.sql.SQLException;

/*
  测试c3p0数据库连接池
  一种硬编码
  另一种 写配置文件（xml）类型的
 */
public class pooldemo_01 {
    public static void main(String[] args) throws PropertyVetoException, SQLException {

        /*ComboPooledDataSource cpds=new ComboPooledDataSource();
        cpds.setDriverClass("com.mysql.jdbc.Driver");
        cpds.setJdbcUrl("jdbc:mysql://localHost:3306/student_manage");
        cpds.setUser("root");
        cpds.setPassword("856736");
        Connection conn = cpds.getConnection();
        System.out.println(conn);
        DataSource.destory(cpds);
        */

        //------------------------------------------------------
        ComboPooledDataSource cpds=new ComboPooledDataSource("intergalactoApp");
        Connection conn = cpds.getConnection();
        System.out.println(conn);
        DataSources.destroy(cpds);

    }
}
